package com.lightjet.macross.base.awf.service.impl;

import com.lightjet.macross.base.awf.domain.BizFormIndex;
import com.lightjet.macross.base.awf.repository.BizFormIndexRepository;
import com.lightjet.macross.base.awf.service.BizFormIndexService;
import com.lightjet.macross.common.core.BaseServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author : lijia
 * @version : 1.0 2019-02-15 16:54
 * description : 流程表单索引表服务层接口实现
 */

@Service
public class BizFormIndexServiceImpl extends BaseServiceImpl<BizFormIndex,Integer> implements BizFormIndexService {

    /**
     * description:根据流程定义Id 获取流程表单的索引
     *
     * @param prosinstdefid
     */
    @Override
    public List<BizFormIndex> GetFormIndexes(String prosinstdefid) {
        List<BizFormIndex> list = ((BizFormIndexRepository) baseRepository).findByProcinstdefIdOrderBySort(prosinstdefid);
        if((list==null||list.size()==0)&& (prosinstdefid.contains(":")))//如果按照流程含版本号的key找不到索引 则尝试 不含版本号的流程set key
        {
            list =((BizFormIndexRepository) baseRepository).findByProcinstdefIdOrderBySort(prosinstdefid.split(":")[0]);
        }
        return list;
    }

    /**
     * Description //获取索流程定义分组集合
     *
     * @return java.util.List<java.lang.String>
     * CreateTime 2019/5/4 13:57
     * @author lijia
     * @Param []
     **/
    @Override
    public List<String> FindProcinstDefIdGroup() {
        return ((BizFormIndexRepository) baseRepository).findProcinstDefIdGroup();
    }


}
